<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ include file="pub/top_list2.jsp"%> 
<%
 String names = (String) request.getSession().getAttribute("name");
String sql = "select * from member where userid=?";
String[] params = new String[1];
params[0] =names; 
List<Map<String, Object>> list= db.queryList(sql, params);
String tx="";
String sex="";
String nickname="";
String hym="";
String uid="";

for (Map<String, Object> m : list) {
	hym=(String)m.get("UserID");
	tx=(String)m.get("touxiang");
	sex=(String)m.get("usex");		
	nickname=(String)m.get("NickName");	
	/* uid=(String)m.get("UserID"); */
}


%>
<script type="text/javascript">
$(document).ready(function() {	
	$("#hym").text('<%=hym %>');
	$("#tx").text('<%=tx %>');
	$("#nc").html('<%=nickname %>');
	var sex='<%=sex %>'
	if(sex=='男'){
		document.getElementById("xb")[0].selected=true;
	}else{
		document.getElementById("xb")[1].selected=true;
	}
	
	
});
 function xgxb(a){
	var sex='<%=sex %>'
	var xb;
	if(a==1){
		xb='男';
	}else{
		xb='女';
	}
	if(sex!=xb){
		$.ajax({
	  		type:"post",
			url:"sexAjax.jsp",
			dataType:"text",
			async : false,
			cache : false,
			data:"usex="+xb,
			xhrFields: {
	     	      withCredentials: true
	    	   },
	    	crossDomain: true,
			success:function(){
				alert("您的性别修改成功");		
			},
			error:function(e){
				console.log(e)
			}
		}); 
	}
	
	
} 

function fun1(){
	alert("会员名作为登录名不可修改")
}
</script>
<body>
	<header class="top-header">
			<a class="icona" href="self.jsp">
					<img src="images/left.png"/>
				</a>
			<h3>我的资料</h3>
			<!-- <a class="text" href="datumall.jsp">修改资料</a> -->
			</a>
	</header>
	
	<div class="contaniner">
		<ul class="self-data">
			<li>
				<a href="#">
					<p>头像</p>
					<span><img src="images/right.png"/></span>
					<figure >
						<%if(tx==null) {%>
							<img src="img/touxiang.png" style="width:36px;height:36px;"/>
						<%}else{ %>
							<img src="<%=tx%>" style="width:36px;height:36px;"/>
						<%} %>
					</figure>
				</a>
			</li>
			<li>
				<a href="#" onclick="fun1()">
					<p>会员名</p>
					<span><!-- <img src="images/right.png"/> --></span>
					<small id="hym"></small>
				</a>
			</li>
			<li>
				<a href="namechange.jsp">
					<p>昵称</p>
					<span><img src="images/right.png"/></span>
					<small id="nc"></small>
				</a>
			</li>
			<li>
				<a href="#">
					<p>性别</p>
					<span><img src="images/right.png"/></span>
					
						<select id="xb" name="xb" onchange="xgxb(this.options[this.selectedIndex].value)">
							<option value="1">男</option>
							<option value="2">女</option>
						</select>						
				</a>
			</li>
		</ul>
	</div>
	
	
	
	

</body>

</html>